package com.example.my_demo.mapper;

import com.example.my_demo.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface UserMapper {
    @Select("select * from user where id=#{id}")
    User getUserById(@Param("id") Integer id);

    @Insert("insert into user values( NULL,#{username},#{password},#{age},#{sex})")
    int insertUser(@Param("username") String username,@Param("password") String password ,@Param("age") int age,@Param("sex") String sex);

    @Update("update user set username=#{username} ," +
            "password=#{password},age=#{age},sex=#{sex} where id=#{id}")
    int updateUser(@Param("username") String username,@Param("password")
     String password,@Param("age") int age,@Param("sex") String sex,@Param("id") int id);

    @Delete("delete from user where id=#{id}")
    int deleteUser(@Param("id") int id);

    @Select("select * from user")
    List<User> getAllUser();
}
